package top.haijunit.navi.auth.domain;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import top.haijunit.framework.validation.ValidChecks;
import top.haijunit.navi.auth.core.WorkConstant;

import java.util.HashMap;
import java.util.Map;

/**
 * 角色新增对象
 *
 * @author zhanghaijun
 * @since 2024-08-20
 */
@Data
@Schema(description = "角色对象")
public class RoleInfo {

    @Schema(description = "角色编码", example = WorkConstant.DEFAULT_ID_STR)
    @NotBlank(message = "角色编码不能为空", groups = {ValidChecks.GroupEdit.class})
    private String roleId;

    @Schema(description = "角色名称", example = "系统管理员")
    @NotBlank(message = "角色名称不能为空", groups = {ValidChecks.GroupAdd.class, ValidChecks.GroupEdit.class})
    @Length(max = 16, message = "角色名称长度不能超过16个字符", groups = {ValidChecks.GroupAdd.class, ValidChecks.GroupEdit.class})
    private String roleName;

    @Schema(description = "角色描述信息", example = "管理系统内的配置、权限分配")
    @NotBlank(message = "角色描述信息不能为空", groups = {ValidChecks.GroupAdd.class, ValidChecks.GroupEdit.class})
    @Length(max = 128, message = "角色描述信息长度不能超过128个字符", groups = {ValidChecks.GroupAdd.class, ValidChecks.GroupEdit.class})
    private String remarks;

    @Schema(description = "角色级别", example = "10")
    @Min(value = 1, message = "角色级别不能小于1", groups = {ValidChecks.GroupAdd.class, ValidChecks.GroupEdit.class})
    private Integer roleLevel = 1;

    @Schema(description = "权限列表", example = "{\"1\":1,\"2\":0}")
    @NotNull(message = "权限列表不能为空", groups = {ValidChecks.GroupAdd.class, ValidChecks.GroupEdit.class})
    private Map<Long, Integer> permissionMap = new HashMap<>();
}
